<? ini_set('memory_limit','1000M');
$unt=($ub=='')?'Semua Unit':$this->main_model->rdb('akun_unitbussiness','nm_unit',"where id_unit='".$ub."'");
?>
<style>
body { margin-top:25; font-size:12px;}
		.b_line { border-bottom:1px #AAAAAA solid; height:25px; font-size:14px}
		.border_t{border-top:1px inset #EEE;}
		.border_b{border-bottom:1px inset #EEE;}
		.border_l{border-left:1px inset #EEE;}
		.border_r{border-right:1px inset #EEE;}
		.xx:hover {cursor:pointer; background:#99FF99;}
		.xy:hover {cursor:pointer; background:#F30;}
		.box{border:1px solid #003}
		.box_t{border-top:1px solid #003;}
		.box_lbr{border:1px solid #003; border-top:none}
		.box_ltr{border:1px solid #003; border-bottom:none}
		.box_l{border-left:1px solid #003;}
		.box_r{border-right:1px solid #003;}
		.box_lb{border-left:1px solid #003;border-bottom:1px solid #003;}
		.box_rb{border-right:1px solid #003;border-bottom:1px solid #003;}
		.box_tb{border-top:1px solid #003; border-bottom:1px solid #003;}
		.list_genap{cursor:pointer; background-color:#6699FF;}
		.list_ganjil{cursor:pointer; background-color:#9966FF;}
		.list_closed{cursor:pointer; background-color:#FF99FF;}
</style>
<table style='border-collapse:collapse' width='100%'>
	<tr align='center'><td colspan='5'><B><?=$coy;?></B><br><?=$add;?></td></tr>
	<tr align='center'><td colspan='5'><h2>Laporan Neraca Harian</h2></td></tr>
	<tr align=''><td colspan='5'></b><hr></td></tr>
	<thead>
	<tr><td>Periode :<?=$from_tgl;?> </td><td colspan='2'>&nbsp;</td><td align='right' colspan='3'>Unit : <b><?=empty($unt)?"Konsolidasi":$unt;?></b></td></tr>
	<tr class='list_genap' align='center'>
		<th class='box_tb' width='40%'>Keterangan</th>
		<th class='box_tb' width='15%'>Saldo Awal</th>
		<th class='box_tb' width='15%'>Mutasi Debet</th>
		<th class='box_tb' width='15%'>Mutasi Kredit</th>
		<th class='box_tb' width='15%'>Saldo Akhir</th>
	</tr>
	</thead><tbody>
<? 
	$jml=0;$jml2=0;$n=0;
	$ts_awal=0;$ts_debet=0;$ts_kredit=0;
	$where=($ub=='')?'':" and id_unit='".$ub."'";
 	foreach($lst as $r){
	$n++;
	$s_awal=0;$s_debet=0;$s_kredit=0;
		 $jml=$this->main_model->rdb('v_akun_neraca','count(kd_akun) as kd_akun',"where kd_akun < 200");
		 $jml2=$this->main_model->rdb('v_akun_neraca','count(kd_akun) as kd_akun',"where kd_akun >= 200 and kd_akun < 400");
		 $s_awal=$this->main_model->rdb('v_jurnal','(sum(debet)-sum(kredit)) as saldo',"where tgl_trans < '".tgltoSql($from_tgl)."' and cid_parent='".$r->kd_neraca."' $where group by cid_parent");
		 $s_debet=$this->main_model->rdb('v_jurnal','(sum(debet)) as saldo',"where tgl_trans = '".tgltoSql($from_tgl)."' and cid_parent='".$r->kd_neraca."' $where group by cid_parent");
		 $s_kredit=$this->main_model->rdb('v_jurnal','(sum(kredit)) as saldo',"where tgl_trans = '".tgltoSql($from_tgl)."' and cid_parent='".$r->kd_neraca."' $where group by cid_parent");
	?>
		<tr class=''>
			<td class=''><font color="#FFFFFF"><?=str_repeat("x",(strlen($r->kd_akun)-1));?></font><?=$r->kd_neraca.". ".$r->cnama;?></td>
			<td class='' align='right'><?=number_format((int)$s_awal,2) ;?></td>
			<td class='' align='right'><?=number_format((int)$s_debet,2) ;?></td>
			<td class='' align='right'><?=number_format((int)$s_kredit,2) ;?></td>
			<td class='' align='right'><?=number_format((int)(($s_awal+$s_debet)-(int)$s_kredit),2) ;?></td>
		</tr>
<?
	$ts_awal +=$s_awal;$ts_debet +=$s_debet;$ts_kredit +=$s_kredit;
		if($n==$jml || $n==($jml+$jml2)){
		?>
			<tr class='list_closed' align='right'>
				<td class='box_tb' align='left'><font color="#FF99FF">
				<?=str_repeat("x",(strlen($r->kd_akun)-1));?></font><b>Total</b></td>
				<td class='box_tb'><?=number_format((int)$ts_awal,2);?></td>
				<td class='box_tb'><?=number_format((int)$ts_debet,2);?></td>
				<td class='box_tb'><?=number_format((int)$ts_kredit,2);?></td>
				<td class='box_tb'><?=number_format((int)($ts_awal+$ts_debet)-(int)$ts_kredit,2);?></td>
			</tr>
		<? 
		}
	}
?>
		</tbody>
		<tr class='' align='' >
			<td class=''><?=$this->main_model->rdb('v_akun_neraca','cnama',"where kd_neraca='307' and kd_akun='307'") ;?></td>
			<td class=''><? ;?></td>
			<td class=''>&nbsp;</td>
			<td class=''>&nbsp;</td>
			<td class=''>&nbsp;</td>
		</tr>
	
	<!--footer / kolom sign-->
			<tr>
				<td colspan='1'></td>
				<td colspan='2' align='center' class='box'><?='Yang memeriksa';?></td>
				<td colspan='2' class='box' align='center'><?='Yang membuat';?></td>
				<td colspan='' class='box_l' align='center' valign='top'>&nbsp;</td>
			</tr>
			<tr height="65px">
			<td colspan='1'><pre>&nbsp;
			&nbsp;
			&nbsp;
			&nbsp;
			</pre></td>
			<td colspan='2' class='box' align='center' valign='top'>&nbsp;</td>
			<td colspan='2' class='box' align='center' valign='top'>&nbsp;</td>
			<td colspan='' class='box_l' align='center' valign='top'>&nbsp;</td>
			</tr>
</table>